//
// Created by Incredible on 17/3/16.
//

#ifndef HEAPSORT_HEAPSORT_H
#define HEAPSORT_HEAPSORT_H

#include <iostream>
#include "SortTestHelper.h"
#include "MergeSort.h"
#include "quickSort.h"
#include "Heap.h"


template<typename T>
void heapSort1(T arr[], int n) {

    MaxHeap<T> maxHeap = MaxHeap<T>(n);

    for (int i = 0; i < n; ++i) {
        maxHeap.insert(arr[i]);
    }

    for (int j = n - 1; j >= 0; j--) {
        arr[j] = maxHeap.extracMax();
    }
}

template<typename T>
void heapSort2(T arr[], int n) {

    MaxHeap<T> maxHeap = MaxHeap<T>(arr, n);

    for (int j = n - 1; j >= 0; j--) {
        arr[j] = maxHeap.extracMax();
    }
}

#endif //HEAPSORT_HEAPSORT_H
